import { shallowMount } from "@vue/test-utils";
import { describe, expect, test } from "vitest";

import Button from "@components/common/button/src/button.vue";
import { IParam } from "@/core";

const ButtonType: IParam = {
    link: 'ant-btn-link',
    default: 'ant-btn-default',
    primary: 'ant-btn-primary',
    ghost: 'ant-btn-background-ghost',
    dashed: 'ant-btn-dashed',
    text: 'ant-btn-text'
}
const shape: IParam = {
    circle: 'ant-btn-circle',
    round: 'ant-btn-round'
}

describe("按钮", () => {
    Object.keys(ButtonType).forEach((key: string) => {
        test(`按钮${key}类型`, async () => {
            const wrapper = shallowMount(Button, {
                props: {
                    type: ButtonType[key],
                },
            });
            wrapper.find(ButtonType[key]).exists();
        });
    })
    Object.keys(shape).forEach((key: string) => {
        test(`按钮${key}形状`, async () => {
            const wrapper = shallowMount(Button, {
                props: {
                    shape: shape[key],
                },
            });
            wrapper.find(shape[key]).exists();
        });
    })
    test("点击事件", async () => {
        const wrapper = shallowMount(Button, {
          props: {
            onClick: ($event: any) => {
                console.log($event, '按钮点击');
            },
          },
        });
        await wrapper.get("a-button").trigger("click");
      });
});